package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.efast.dmom.mes.bean.Printer;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.PrinterService;

@Controller
@RequestMapping("/printer")
public class PrinterController {
	@Autowired
	private PrinterService printerService;
	@RequestMapping(value = "/operateToBasicByParam")
	public @ResponseBody ResultBean operateToBasicByParam(@RequestBody Printer  printer) {
		if (printer.getModificationFlag() == IModificationFlags.NEW) {
			return printerService.save(printer);
			// Judge update
		} else if (printer.getModificationFlag() == IModificationFlags.MODIFIED) {
			return printerService.update(printer);
			// Judge to delete
		} else if (printer.getModificationFlag() == IModificationFlags.DELETED) {
			return printerService.delete(printer);
		}
		return null;
		
	}
	
	@RequestMapping(value = "/batchDelete")
	public @ResponseBody ResultBean batchDelete(@RequestBody List<Printer> listPrinter) {
		
		return printerService.batchDelete(listPrinter);
	}
} 
